package com.student.manage.entity.model;

import com.student.manage.entity.User;

import java.util.Map;

public class RegisterResult {
    private Integer code;
    private String msg;
    private User user;

    private Map<String, String> errorMsg;


    private RegisterResult(String msg, Integer code) {
        this.msg = msg;
        this.code = code;
    }

    private RegisterResult(String msg, Integer code, Map<String, String> errorMsg) {
        this.msg = msg;
        this.code = code;
        this.errorMsg = errorMsg;
    }


    private RegisterResult(String msg, Integer code, User user) {
        this.msg = msg;
        this.code = code;
        this.user = user;
    }

    public static RegisterResult success(User user) {
        return new RegisterResult("注册成功", 200, user);
    }

    public static RegisterResult fail(String msg, Map<String, String> errorMsg) {
        return new RegisterResult(msg, 500, errorMsg);
    }


    public boolean isSuccess() {
        return code == 200;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Map<String, String> getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(Map<String, String> errorMsg) {
        this.errorMsg = errorMsg;
    }
}
